package com.travel.controller;

import com.qianfeng.util.ResultMsg;
import com.travel.entity.TbCart;
import com.travel.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/adminCart")
/*@CrossOrigin(allowCredentials = "true")*/
public class AdminCartController {
    @Autowired
    CartService cartService;
    /**
     * 添加车票
     * */
    @GetMapping("/addCart")
    public ResultMsg addCart(TbCart tbCart){
        return cartService.addCart(tbCart);
    }
    /**
     * 删除车票
     * */
    @GetMapping("/deleteCart/{id}")
    public ResultMsg deleteCart(@PathVariable("id") int id){
        return cartService.deleteCart(id);
    }
    /**
     * 修改车票
     * */
    @PostMapping("/updateCart")
    public ResultMsg updateCart(@RequestBody TbCart tbCart){
        return cartService.updateCart(tbCart);
    }
    /**
     * 查询所有车票
     * */
    @GetMapping("/findAllCart")
    public ResultMsg findAllCart(@RequestParam(required = false,defaultValue = "1") int current, @RequestParam(required = false,defaultValue = "5") int size){
        return cartService.findAllCart(current,size);
    }
    /**
     * 通过id查询车票
     * */
    @GetMapping("/getCartById/{carId}")
    public ResultMsg getCartById(@PathVariable("carId") int carId){
        return cartService.getCartById(carId);
    }





}
